/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * plantilla.java
 *
 * Created on 31/10/2011, 12:00:51 AM
 */
package vista.panel.altas;

import controlador.CargaPanel;
import controlador.ControlEventos;
import javax.swing.JPanel;
import modelo.Nave;
import modelo.ReferenciaSustrato;
import modelo.Sustrato;
import modelo.SustratoNave;

/**
 *
 * @author Elias Mendoza
 */
public class AltaSustrato extends javax.swing.JPanel {
  CargaPanel cargaPanel;
  ControlEventos ce;

  /** Creates new form plantilla */
  public AltaSustrato(CargaPanel cargaPanel) {
    initComponents();
    ce = new ControlEventos();
    ce.llenaComponenteReferencia(referencia);
    ce.llenaComponenteNave(nave);
    this.cargaPanel=cargaPanel;
    
  }

  /** This method is called from within the constructor to
   * initialize the form.
   * WARNING: Do NOT modify this code. The content of this method is
   * always regenerated by the Form Editor.
   */
  @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        panel2 = new javax.swing.JPanel();
        jSplitPane1 = new javax.swing.JSplitPane();
        jLabel1 = new javax.swing.JLabel();
        nombre = new javax.swing.JTextField();
        jSplitPane2 = new javax.swing.JSplitPane();
        jLabel2 = new javax.swing.JLabel();
        constitucion = new javax.swing.JTextField();
        jSplitPane3 = new javax.swing.JSplitPane();
        jLabel3 = new javax.swing.JLabel();
        descripcion = new javax.swing.JTextField();
        jSplitPane4 = new javax.swing.JSplitPane();
        jLabel4 = new javax.swing.JLabel();
        jSplitPane7 = new javax.swing.JSplitPane();
        ultModificacion = new javax.swing.JTextField();
        jButton3 = new javax.swing.JButton();
        jSplitPane5 = new javax.swing.JSplitPane();
        jLabel5 = new javax.swing.JLabel();
        referencia = new javax.swing.JComboBox();
        jSplitPane8 = new javax.swing.JSplitPane();
        jLabel6 = new javax.swing.JLabel();
        nave = new javax.swing.JComboBox();
        jPanel1 = new javax.swing.JPanel();
        jSplitPane6 = new javax.swing.JSplitPane();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        borrar = new javax.swing.JButton();
        siguiente = new javax.swing.JButton();

        setBackground(new java.awt.Color(255, 255, 255));
        setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Registrar Sustrato", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Maiandra GD", 1, 14))); // NOI18N
        setLayout(new java.awt.GridBagLayout());

        panel2.setBackground(new java.awt.Color(255, 255, 255));
        panel2.setLayout(new java.awt.GridLayout(7, 0));

        jSplitPane1.setBackground(new java.awt.Color(255, 255, 255));
        jSplitPane1.setBorder(null);
        jSplitPane1.setDividerSize(0);
        jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
        jSplitPane1.setMinimumSize(new java.awt.Dimension(51, 51));
        jSplitPane1.setOpaque(false);

        jLabel1.setBackground(new java.awt.Color(255, 255, 255));
        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel1.setForeground(new java.awt.Color(0, 153, 102));
        jLabel1.setText("Nombre:");
        jSplitPane1.setLeftComponent(jLabel1);

        nombre.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
        nombre.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));
        jSplitPane1.setRightComponent(nombre);

        panel2.add(jSplitPane1);

        jSplitPane2.setBackground(new java.awt.Color(255, 255, 255));
        jSplitPane2.setBorder(null);
        jSplitPane2.setDividerSize(0);
        jSplitPane2.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);

        jLabel2.setBackground(new java.awt.Color(255, 255, 255));
        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel2.setForeground(new java.awt.Color(0, 153, 102));
        jLabel2.setText("Constitución:");
        jSplitPane2.setLeftComponent(jLabel2);

        constitucion.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
        jSplitPane2.setRightComponent(constitucion);

        panel2.add(jSplitPane2);

        jSplitPane3.setBackground(new java.awt.Color(255, 255, 255));
        jSplitPane3.setBorder(null);
        jSplitPane3.setDividerSize(0);
        jSplitPane3.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);

        jLabel3.setBackground(new java.awt.Color(255, 255, 255));
        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel3.setForeground(new java.awt.Color(0, 153, 102));
        jLabel3.setText("Descripción:");
        jSplitPane3.setLeftComponent(jLabel3);
        jSplitPane3.setRightComponent(descripcion);

        panel2.add(jSplitPane3);

        jSplitPane4.setBackground(new java.awt.Color(255, 255, 255));
        jSplitPane4.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        jSplitPane4.setDividerSize(3);
        jSplitPane4.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);

        jLabel4.setBackground(new java.awt.Color(255, 255, 255));
        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel4.setForeground(new java.awt.Color(0, 153, 102));
        jLabel4.setText("Ultima Modificación:");
        jSplitPane4.setLeftComponent(jLabel4);

        jSplitPane7.setBackground(new java.awt.Color(255, 255, 255));
        jSplitPane7.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        jSplitPane7.setDividerSize(3);
        jSplitPane7.setEnabled(false);

        ultModificacion.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        ultModificacion.setText("2000-12-12");
        ultModificacion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ultModificacionActionPerformed(evt);
            }
        });
        jSplitPane7.setLeftComponent(ultModificacion);

        jButton3.setBackground(new java.awt.Color(255, 255, 255));
        jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/vista/img/calendario.png"))); // NOI18N
        jButton3.setBorder(null);
        jSplitPane7.setRightComponent(jButton3);

        jSplitPane4.setRightComponent(jSplitPane7);

        panel2.add(jSplitPane4);

        jSplitPane5.setBackground(new java.awt.Color(255, 255, 255));
        jSplitPane5.setBorder(null);
        jSplitPane5.setDividerSize(0);
        jSplitPane5.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
        jSplitPane5.setEnabled(false);

        jLabel5.setBackground(new java.awt.Color(255, 255, 255));
        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel5.setForeground(new java.awt.Color(0, 153, 102));
        jLabel5.setText("Referencia:");
        jLabel5.setMaximumSize(new java.awt.Dimension(112, 15));
        jLabel5.setMinimumSize(new java.awt.Dimension(112, 15));
        jSplitPane5.setLeftComponent(jLabel5);

        referencia.setFont(new java.awt.Font("Times New Roman", 1, 10));
        referencia.setMaximumRowCount(10);
        referencia.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                referenciaActionPerformed(evt);
            }
        });
        jSplitPane5.setRightComponent(referencia);

        panel2.add(jSplitPane5);

        jSplitPane8.setBackground(new java.awt.Color(255, 255, 255));
        jSplitPane8.setBorder(null);
        jSplitPane8.setDividerSize(0);
        jSplitPane8.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
        jSplitPane8.setEnabled(false);

        jLabel6.setBackground(new java.awt.Color(255, 255, 255));
        jLabel6.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel6.setForeground(new java.awt.Color(0, 153, 102));
        jLabel6.setText("Nave:");
        jLabel6.setMaximumSize(new java.awt.Dimension(112, 15));
        jLabel6.setMinimumSize(new java.awt.Dimension(112, 15));
        jSplitPane8.setLeftComponent(jLabel6);

        nave.setFont(new java.awt.Font("Times New Roman", 1, 14));
        nave.setMaximumRowCount(10);
        nave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                naveActionPerformed(evt);
            }
        });
        jSplitPane8.setRightComponent(nave);

        panel2.add(jSplitPane8);

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));
        jPanel1.setLayout(new java.awt.GridBagLayout());

        jButton1.setFont(new java.awt.Font("Maiandra GD", 1, 12));
        jButton1.setText("jButton1");
        jSplitPane6.setLeftComponent(jButton1);

        jButton2.setFont(new java.awt.Font("Maiandra GD", 1, 12));
        jButton2.setText("jButton2");
        jSplitPane6.setLeftComponent(jButton2);

        borrar.setFont(new java.awt.Font("Maiandra GD", 1, 14)); // NOI18N
        borrar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/vista/img/borrar.png"))); // NOI18N
        borrar.setBorder(null);
        jSplitPane6.setRightComponent(borrar);

        siguiente.setFont(new java.awt.Font("Maiandra GD", 1, 14)); // NOI18N
        siguiente.setIcon(new javax.swing.ImageIcon(getClass().getResource("/vista/img/siguiente.png"))); // NOI18N
        siguiente.setBorder(null);
        siguiente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                siguienteActionPerformed(evt);
            }
        });
        jSplitPane6.setLeftComponent(siguiente);

        jPanel1.add(jSplitPane6, new java.awt.GridBagConstraints());

        panel2.add(jPanel1);

        add(panel2, new java.awt.GridBagConstraints());
    }// </editor-fold>//GEN-END:initComponents

  private void siguienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_siguienteActionPerformed
    // TODO add your handling code here:
    Sustrato s = new Sustrato();
    s.setConstitucion(constitucion.getText());
    s.setDescripcion(descripcion.getText());
    s.setNombre(nombre.getText());
    ReferenciaSustrato rs = (ReferenciaSustrato) referencia.getSelectedItem();
    Nave n = (Nave) nave.getSelectedItem();
    s.setReferenciaSustrato(rs);
    
    SustratoNave sn = new SustratoNave();
    sn.setNaveFK(n);
    sn.setSustratoFK(s);
    
    cargaPanel.cargaPanelSuatratoGrupo(cargaPanel,sn);
    
  }//GEN-LAST:event_siguienteActionPerformed

  private void referenciaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_referenciaActionPerformed
    // TODO add your handling code here:
  }//GEN-LAST:event_referenciaActionPerformed

  private void naveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_naveActionPerformed
    // TODO add your handling code here:
  }//GEN-LAST:event_naveActionPerformed

  private void ultModificacionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ultModificacionActionPerformed
    // TODO add your handling code here:
  }//GEN-LAST:event_ultModificacionActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton borrar;
    private javax.swing.JTextField constitucion;
    private javax.swing.JTextField descripcion;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JSplitPane jSplitPane1;
    private javax.swing.JSplitPane jSplitPane2;
    private javax.swing.JSplitPane jSplitPane3;
    private javax.swing.JSplitPane jSplitPane4;
    private javax.swing.JSplitPane jSplitPane5;
    private javax.swing.JSplitPane jSplitPane6;
    private javax.swing.JSplitPane jSplitPane7;
    private javax.swing.JSplitPane jSplitPane8;
    private javax.swing.JComboBox nave;
    private javax.swing.JTextField nombre;
    private javax.swing.JPanel panel2;
    private javax.swing.JComboBox referencia;
    private javax.swing.JButton siguiente;
    private javax.swing.JTextField ultModificacion;
    // End of variables declaration//GEN-END:variables
}
